#pragma once
#include "UIControl.h"
#include <afxtempl.h>
struct MenuItem
{
	int nCommand;
    CString sText;
	void *pData;
};

class CUIMenu :
	public CUIControl
{
public:
	CUIMenu(void);
	~CUIMenu(void);

	virtual void Render(CDC *pDC);
	virtual BOOL OnLButtonDown(UINT nFlags, CPoint point);
	virtual BOOL OnLButtonUp(UINT nFlags, CPoint point);
	virtual BOOL OnMouseOver(UINT nFlags, CPoint point);
	virtual BOOL OnMouseOut() { return TRUE;};
	virtual BOOL OnRButtonUp(UINT nFlags, CPoint point);
public:
	void Create(int nItemWidth, int nItemHeight, CUIControl *pParent);
	void AddItem(int nCommand, CString sText);
	void DeleteAllItem();
	void SetItemData(int nIndex,void *pItemData); 
	void *GetItemData(int nIndex);
    void Pop(CPoint pt,int nBottomLimit);
	int GetItemHeight() {return m_nItemHeight;};
	void SetItemHeight(int nItemHeight) {m_nItemHeight = nItemHeight;};
	COLORREF GetBackgroundColor() {return m_crBackground;};
	void SetBackgroundColor(COLORREF crBackground) {m_crBackground = crBackground;};
	COLORREF GetHoverColor() {return m_crHoverItem;};
	void SetHoverColor(COLORREF crHoverItem) {m_crHoverItem = crHoverItem;};
	COLORREF GetTextColor() {return m_crText;};
	void SetTextColor(COLORREF crText) {m_crText = crText;};
	COLORREF GetLineColor() {return m_crLine;};
	void SetLineColor(COLORREF crLine) {m_crLine = crLine;};
	int HitTest(CPoint pt);
	MenuItem& GetItemByCommand(int nCommand);

	void ClearCapture();
protected:

	CArray<MenuItem> m_listItem;
    int m_nItemHeight;
	COLORREF m_crBackground;
	COLORREF m_crHoverItem;
	COLORREF m_crText;
    COLORREF m_crLine;
    int m_nHoverItem;
};
